package com.iscas.green.extralindextest.config;

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

/**
 * 应用主配置类，根据配置文件条件性导入其他配置
 */
@Configuration
public class AppConfig {

    /**
     * MySQL配置，仅在app.feature.mysql.enabled为true或未定义时启用
     */
    @Configuration
    @ConditionalOnProperty(name = "app.feature.mysql.enabled", havingValue = "true", matchIfMissing = true)
    @Import(MySQLConfig.class)
    public static class MySQLConfiguration {
    }
    
    /**
     * Redis配置，仅在app.feature.redis.enabled为true或未定义时启用
     */
    @Configuration
    @ConditionalOnProperty(name = "app.feature.redis.enabled", havingValue = "true", matchIfMissing = true)
    @Import(RedisConfig.class)
    public static class RedisConfiguration {
    }
    
    /**
     * MongoDB配置，仅在app.feature.mongodb.enabled为true或未定义时启用
     */
    @Configuration
    @ConditionalOnProperty(name = "app.feature.mongodb.enabled", havingValue = "true", matchIfMissing = true)
    @Import(MongoConfig.class)
    public static class MongoConfiguration {
    }
    
    /**
     * ClickHouse配置，仅在app.feature.clickhouse.enabled为true或未定义时启用
     */
    @Configuration
    @ConditionalOnProperty(name = "app.feature.clickhouse.enabled", havingValue = "true", matchIfMissing = true)
    @Import(ClickHouseConfig.class)
    public static class ClickHouseConfiguration {
    }
    
    /**
     * PostgreSQL配置，仅在app.feature.postgresql.enabled为true或未定义时启用
     */
    @Configuration
    @ConditionalOnProperty(name = "app.feature.postgresql.enabled", havingValue = "true", matchIfMissing = true)
    @Import(PostgreSQLConfig.class)
    public static class PostgreSQLConfiguration {
    }
} 